package form;

import java.awt.Toolkit;

import javax.swing.ImageIcon;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import menu.Menu;

import common.DesktopPane;

public class App extends JFrame{
	private static String version = "1.01";
	private static String revision = "r30";
	private static String date = "09/04/2012";
	
	private JDesktopPane desktop;
	
	public static String getVersion(){
		return version + " " + revision;
	}
	public static String getDateVersion(){
		return date;
	}
	
	public App() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(Toolkit.getDefaultToolkit().getScreenSize());
		setSize(1024,700);
		//setUndecorated(true);
		setResizable(false);
		setTitle("Edevaldo Cabelereiro's");
		setIconImage(new ImageIcon(ClassLoader.getSystemResource("img/icon_hairdresser.PNG")).getImage());
		setJMenuBar(new Menu(this));
		add(getDesktop());
				
		setVisible(true);

		new FrmSplash();
	}
	
	private JDesktopPane getDesktop(){
		if(desktop == null){
			desktop = new DesktopPane();
//			JInternalFrame i = new JInternalFrame();
//			i.setSize(this.getSize());
//			i.setBorder(null);
//			i.setVisible(true);
//			i.setJMenuBar(new Menu(this));
//			i.addFocusListener(new FocusListener() {
//				
//				@Override
//				public void focusLost(FocusEvent arg0) {
//					// TODO Auto-generated method stub
//					
//				}
//				
//				@Override
//				public void focusGained(FocusEvent arg0) {
//					JInternalFrame iF = (JInternalFrame) arg0.getSource();
//					iF.moveToBack();
//				}
//			});
//			desktop.add(i);
		}
		return desktop;
	}
	
	public void addFrame(JInternalFrame iFrame){
		desktop.add(iFrame);
		iFrame.moveToFront();
	}
	
	public static void main(String[] args) {
		try{
			String lnf = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
			UIManager.setLookAndFeel(lnf);
		}catch(ClassNotFoundException e ){
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (UnsupportedLookAndFeelException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		new App();				
	}
}
